package cn.net.zj.scan.adapter;

/**
 * Created by Administrator on 2016/11/25.
 */

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;



import java.util.List;

import cn.net.zj.scan.R;
import cn.net.zj.scan.bean.LabelBean;


public class InHouseListAdapter extends
        RecyclerView.Adapter<InHouseListAdapter.ViewHolder>
{

    private LayoutInflater mInflater;
    private List<LabelBean> mDatas;
    Context mContext;
    public InHouseListAdapter(Context context, List<LabelBean> datats)
    {
        mInflater = LayoutInflater.from(context);
        mDatas = datats;
        mContext =context;
    }

    public static class ViewHolder extends RecyclerView.ViewHolder
    {
        public ViewHolder(View arg0)
        {
            super(arg0);
        }

        TextView textView1,tv_state,tv_position;
    }

    @Override
    public int getItemCount()
    {
        return mDatas.size();
    }


    public void clear() {
        mDatas.clear();
        notifyDataSetChanged();
    }

    /**
     * 创建ViewHolder
     */
    @Override
    public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i)
    {
        View view = mInflater.inflate(R.layout.item_label,
                viewGroup, false);
        ViewHolder viewHolder = new ViewHolder(view);

        viewHolder.textView1 = (TextView) view.findViewById(R.id.tv_label_in);
        viewHolder.tv_state = (TextView) view.findViewById(R.id.tv_state);
        viewHolder.tv_position = (TextView) view.findViewById(R.id.tv_position);

        return viewHolder;
    }

    /**
     * 设置值
     */
    @Override
    public void onBindViewHolder(final ViewHolder viewHolder, final int i)
    {
        viewHolder.textView1.setText(mDatas.get(i).getLabelId()+"");
        viewHolder.tv_state.setText(mDatas.get(i).getState()+"");
        viewHolder.tv_position.setText(i+"");

    }

}